package core;

import java.awt.Container;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;

/**
 *
 * Class which implements the game's window
 */

public class Gambolputty extends JFrame implements WindowListener
{
    private static int DEFAULT_FPS=30;

    private Container container;
    private PlayState ps;

    public Gambolputty()
    {
        super("Gambolputty");
        gameScreenShow();

        addWindowListener(this);
        pack();
        //setResizable(false);
        setVisible(true);

    }

    public void windowActivated(WindowEvent e){}
    public void windowDeactivated(WindowEvent e){}
    public void windowDeiconified(WindowEvent e){}
    public void windowIconified(WindowEvent e){}
    public void windowOpened(WindowEvent e){}
    public void windowClosed(WindowEvent e){}
    public void windowClosing(WindowEvent e)
    {
                ps.stopGame();
    }


    public void gameScreenShow()
    {
        long period=(long)1000.0/DEFAULT_FPS;
        container=getContentPane();
        ps=new PlayState(period*1000000L);
        container.add(ps,"Center");
    }

    public static void main(String[] args) 
    {
        new Gambolputty();
    }

}
